-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement HTTP server for task processing #58
Conversation
f4491c2
to
6703522
Compare
cmd/klient/main.go
Outdated
} | ||
|
||
func execReset(urlPath string) error { | ||
resp, err := http.Get(urlPath) // #nosec G107 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a code comment on why we need #nosec G107
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your changes, thanks for adding them. I meant we should also add why are we ignoring G107
. Something along the lines of "Since the URL is provided by the same user who wants to use the system and not by a third party, a malicious redirect will not be possible". ref https://securego.io/docs/rules/g107.html
We should do the same in other places as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it obvious? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but actually, since we pass address as a command line parameter, it could be a security issue. But not for the fake cluster.
pkg/server/server.go
Outdated
log *logr.Logger | ||
} | ||
|
||
type TaskHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the API is simple, instead of using structs, can we use functions as HTTP handlers? Please see https://www.alexedwards.net/blog/an-introduction-to-handlers-and-servemuxes-in-go (section "Functions as handlers")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can use functions because I need to call eng
from the handler.
g.Add( | ||
func() error { | ||
srv.log.Info("Starting server", "address", srv.s.Addr) | ||
return srv.s.ListenAndServe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need some form of authn and authz? I think a user who is able to access the server will be able to privilege escalate since the user and the server use two different RBAC means. What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to complicate things. This is a local kind cluster, the nodes are virtual. I think authn/authz will be an overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fair point. Then we should add documentation describing the risks for users who want to have a long running cluster, maybe for simulation testing/QA.
I was also wondering; can we leverage the JWT tokens generated for Kubernetes service accounts? Use the tokens for a service account (https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount) for making calls to the Kubernetes API and let the Kubernetes API server handle auth. User will provide the token as a part of the Authorization header.
c135105
to
27bb687
Compare
e5fee69
to
70772aa
Compare
c21015c
to
aea7112
Compare
Signed-off-by: Dmitry Shmulevich <[email protected]>
This PR adds server functionality to knavigator.
To start the server, run "knavigator -port <port#>", for example
Then you can start executing tasks by issuing HTTP requests, for example
or, alternatively, use the client: